﻿using ViewMaker.Core.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ViewMaker.Core;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Data;
using ViewMaker.Core.Tests.Controls;

namespace ViewMaker.Core.Tests
{
    [TestClass()]
    public class TreeViewControlTest
    {
        [TestMethod()]
        public void 標準的なTreeViewLのXAML生成()
        {
            var target = new TreeViewControl { Item = new ViewLayoutItem { Name = "tv001", Caption = "ツリービュー", BindPath = "data" } };
            var parent = TestHelper.CreateTestParent();
            parent.AppendChild(target.CreateXaml(parent)[0]);
            var actual = (TreeView)TestHelper.GetFrameworkElement<ContentControl>(parent).Content;
            Assert.AreEqual("tv001", actual.Name);
            Assert.AreEqual("data", actual.GetBindingExpression(TreeView.ItemsSourceProperty).ParentBinding.Path.Path);
        }

        [TestMethod()]
        public void 選択・展開指定なTreeViewLのXAML生成()
        {
            var target = new TreeViewControl { Item = new ViewLayoutItem { Name = "tv001", Caption = "ツリービュー", BindPath = "data" } };
            target.ItemsSource = "itemSourcePath";
            target.IsSelected = "selectPath";
            target.IsExpanded = "expandPath";
            target.DisplayMember = "displayPath";
            var parent = TestHelper.CreateTestParent();
            parent.AppendChild(target.CreateXaml(parent)[0]);
            var xaml = TestHelper.GetXamlCode(parent);
            var actual = (TreeView)TestHelper.GetFrameworkElement<ContentControl>(parent).Content;
            Assert.AreEqual("tv001", actual.Name);
            Assert.AreEqual("data", actual.GetBindingExpression(TreeView.ItemsSourceProperty).ParentBinding.Path.Path);
        }

        [TestMethod()]
        public void TreeViewControlの編集画面が表示可能()
        {
            var target = new TreeViewControl { Item = new ViewLayoutItem { Name = "tv001", Caption = "ツリービュー", BindPath = "data" } };
            var baml = ViewUtil.BuildContent(target);
            Assert.IsNotNull(baml);
        }

    }
}
